package com.biz.primus.ms.behavior.api;

import com.alibaba.fastjson.JSONArray;
import com.biz.primus.ms.base.api.BaseApiController;
import com.biz.primus.ms.behavior.service.UploadLogService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @author yanweijin
 * @date 2017/9/12
 */
@RestController
@RequestMapping("soa/behaviorService")
public class BehaviorApiController extends BaseApiController {

    @Autowired
    private UploadLogService uploadLogService;


    @ApiOperation("上传行为日志")
    @PostMapping("updateLoadLog")
    void updateLoadLog(@RequestBody JSONArray reqVo){
        try {
            StopWatch sw = new StopWatch();
            sw.start("行为日志上传");
            uploadLogService.sendPostHTTPS(reqVo);
            sw.stop();
            logger.info(sw.prettyPrint());
        } catch (IOException e) {
            logger.warn("用户行为上传失败");
            e.printStackTrace();
        }
    }


}
